package simplefactory;

import javax.xml.parsers.*;

import factorymethod.XMLUtil;
import org.w3c.dom.*;

import java.io.*;
public class XMLUtilTV
{
    //�÷������ڴ�XML�����ļ�����ȡƷ�����ƣ������ظ�Ʒ������
	public static String getBrandName()
	{
		try
		{
			//�����ĵ�����
			DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance();
			DocumentBuilder builder = dFactory.newDocumentBuilder();
			Document doc = null;
			try {
				InputStream inputStream = XMLUtilTV.class.getResourceAsStream("SimpleFactoryconfigTV.xml");
				if (inputStream != null) {
					doc = builder.parse(inputStream);
				} else {
					throw new FileNotFoundException("文件没找到");
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		
			//��ȡ����Ʒ�����Ƶ��ı��ڵ�
			NodeList nl = doc.getElementsByTagName("brandName");
            Node classNode=nl.item(0).getFirstChild();
            String brandName=classNode.getNodeValue().trim();
            return brandName;
           }   
           	catch(Exception e)
           	{
           		e.printStackTrace();
           		return null;
           	}
		}
}
